<!--
* @description 视频回放
* @author zywu
* @date 2021/03/08 15:55:47
!-->
<template>
  <el-dialog title="设置监控回放时间" width="600px" :close-on-click-modal="false" :visible.sync="visible" v-dialogDrag>
    <div v-loading="loading"></div>
    <p style="padding:0 0 20px 20px;color:#999;">系统默认从报警前10秒开始到复位时间结束。请注意，因视频都有保存时间限制，你可能查看不到历史视频。</p>
    <el-form label-width="130px" :model="dataForm" :rules="dataRules" ref="dataForm">
      <el-form-item label="开始结束时间：" prop="time">
        <el-date-picker
          v-model="dataForm.time"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          placeholder="请选择"
          :clearable="false"
          :picker-options="pickerOptions"
          style="width: 100%;"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label-width="0" class="verifyidentity-button">
        <el-button round @click="visible=false">取消</el-button>
        <el-button type="primary" round @click="handleSubmit">开始回放</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import utils from '@/utils/util'
export default {
  data() {
    return {
      visible: false,
      loading: false,
      dataForm: {
        time: [],
      },
      dataRules: {
        time: [
          {
            required: true,
            message: '请选择',
          },
        ],
      },
      pickerOptions: {},
    }
  },

  components: {},

  computed: {},

  created() {},

  mounted() {},

  methods: {
    init(data) {
      this.visible = true
      this.rowData = Object.assign({}, data)
      this.$nextTick(() => {
        this.dataForm.time = [
          utils.ilinkTimeformat.format(
            new Date(
              new Date(data.storageTime || data.createTime).getTime() - 10000
            ),
            'yyyy-MM-dd hh:mm:ss'
          ),
          data.resetTime,
        ]
      })
    },
    handleSubmit() {
      utils.rowShowVedio(
        {
          ...this.rowData,
          startTime: this.dataForm.time[0],
          endTime: this.dataForm.time[1],
        },
        1
      )
      this.visible = false
    },
  },
}
</script>
<style lang='scss'>
</style>